package Test;

import java.io.*;
import java.net.*;
import java.sql.*;
import java.util.*;
import java.util.Date;

/**
 * Blade单元测试
 *
 * @author Chill
 */
public class Test {

    public static void main(String[] args) throws SQLException, ClassNotFoundException, MalformedURLException {
        long startTime = System.currentTimeMillis();   //获取开始时间

        String URL = "/shequtong0122?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=GMT";
        String USER = "root";
        String PASSWORD = "xczg@2019";
        Class.forName("com.mysql.jdbc.Driver");
        Connection dbConn = DriverManager.getConnection(URL, USER, PASSWORD);
        Statement st = dbConn.createStatement();
        ResultSet rs = st.executeQuery("select * from picture_copy1_copy1 limit 0,50");
        // 封装查询结果集
        Map<String, String> urlMap = new HashMap<String, String>();
        Map<String, String> fileNameMap = new HashMap<String, String>();
        List<Map> list = new ArrayList<>();
        while (rs.next()) {
            String id = rs.getString("id");
            System.out.println(id);
            urlMap.put(id, rs.getString("url"));
            fileNameMap.put(id, rs.getString("topic_id") + id);
        }
        list.add(urlMap);
        /*
         * 创建线程
         * */

            for (Map.Entry<String, String> entry : urlMap.entrySet()) {
                System.out.println(""+entry.getKey());
                String filePath = entry.getValue();
                if (null != filePath) {
                    DownloadFilePool pool =  DownloadFilePool.getInstance(
                            entry.getValue(),
                            fileNameMap.get(entry.getKey())+"_"+entry.getKey(),5,null);
                    pool.getFile();

            }
        }



    }
}
